<template>
	<view class="login">
		<view class="sign" @click="open"><i class="ico"></i></view>
		<view class="content">
			<view class="title">
				<view class="title_text">登录注册更精彩</view>
				<view class="desc">
					<view class="desc_text">登录注册表示同意</view>
					<view class="url">《用户协议、隐私条款》</view>
				</view>
			</view>
			<view class="form">
				<view class="item">
					<view class="label"><i class="ico"></i></view>
					<input type="text" placeholder="ID/手机/用户名" @input="getUsername"/>
				</view>
				<view class="item">
					<view class="label"><i class="ico"></i></view>
					<input type="text" placeholder="密码" @input="getPassword"/>
					<view class="icon">
						<text class="ico" v-if="!showPassword" @click="changepassword"></text>
						<text class="ico" v-else @click="changepassword"></text>
					</view>
				</view>
				<view class="item">
					<view class="label"><i class="ico"></i></view>
					<input type="text" placeholder="QQ邮箱" @input="getEmail"/>
				</view>
				<view class="item">
					<view class="label"><i class="ico"></i></view>
					<input type="text" placeholder="验证码" @input="getUcode"/>
					<button @click="getCode">获取验证码</button>
				</view>
				<view class="arrow_region">
					<view class="left">注册新账号</view>
					<view class="right">忘记密码</view>
				</view>
				<view class="btn" @click="register">注册</view>
			</view>
		</view>
		<u-popup :show="show" @close="close" @open="open" mode="top" :round="10">
			<view class="top_region">
				<view class="title">
					<view class="left">服务大厅</view>
					<view class="right" @click="close">
						<view class="text">关闭</view>
						<i class="ico"></i>
					</view>
				</view>
				<view class="content">
					<view class="item">
						<i class="_index ico"></i>
						<view class="text">首页</view>
					</view>
					<view class="item">
						<i class="_huxuan ico"></i>
						<view class="text">互选</view>
					</view>
					<view class="item">
						<i class="_index ico"></i>
						<view class="text">认证</view>
					</view>
					<view class="item">
						<i class="_tg ico"></i>
						<view class="text">视频</view>
					</view>
					<view class="item">
						<i class="_hb ico">
							
							<b>新</b>
						</i>
						<view class="text">推广</view>
					</view>
					<view class="item">
						<i class="_video ico"></i>
						<view class="text">牵线</view>
					</view>
					<view class="item">
						<i class="_myhn ico"></i>
						<view class="text">活动</view>
					</view>
					<view class="item">
						<i class="_article ico"></i>
						<view class="text">学堂</view>
					</view>
					<view class="item">
						<i class="_vip ico"></i>
						<view class="text">开通VIP</view>
					</view>
					<view class="item">
						<image class="iconImg" src="../../static/photo_s0.png" mode=""></image>
						<view class="text">我的</view>
					</view>
				</view>
			</view>
		</u-popup>
	</view>
</template>

<script>
export default {
	name: 'login',
	data() {
		return {
			show: false,
			showPassword:false,
			email:'',
			username:'',
			password:'',
			code:''
		};
	},
	methods: {
		open() {
			this.show = true;
		},
		close() {
			this.show = false;
		},
		changepassword(){
			this.showPassword = !this.showPassword
		},
		async getCode(){
			let data = await this.request({
				url:'/api/service/sendMailCode/' + this.email,
				method:'GET'
			})
			console.log(data)
		},
		getEmail(event){
			this.email = event.detail.value
		},
		getUsername(event){
			this.username = event.detail.value
		},
		getPassword(event){
			this.password = event.detail.value
		},
		getUcode(event){
			this.code = event.detail.value
		},
		async register(){
			let {username,password,email,code} = this
			let data = await this.request({
				url:'/front/register',
				data:{
					username,
					password,
					email,
					code
				},
				method:'POST'
			})
			if(data.code === '200'){
				uni.navigateTo({
					url:'/pages/login/login'
				})
			}
		}
	}
};
</script>

<style lang="scss" scoped>
.login {
	min-height: 100vh;
	background-color: #ffffff;
	.sign {
		position: fixed;
		top: 20rpx;
		right: 30rpx;
		color: #999;
		font-size: 44rpx;
		z-index: 9999;
	}
	.content {
		padding: 76rpx;
		box-sizing: border-box;
		.title {
			.title_text {
				font-size: 60rpx;
			}
			.desc {
				margin-top: 20rpx;
				display: flex;
				align-items: center;
				font-size: 24rpx;
				.desc_text {
				}
				.url {
					color: #ff589b;
				}
			}
		}
		.form {
			margin-top: 100rpx;
			.item {
				display: flex;
				align-items: center;
				width: 100%;
				margin-bottom: 40rpx;
				height: 100rpx;
				overflow: hidden;
				background-color: #f8f8f8;
				border-radius: 40rpx;
				padding: 0 36rpx;
				box-sizing: border-box;
				.label {
					color: #bbb;
					font-size: 46rpx;
					border-right: 2rpx solid #bbb;
					padding-right: 30rpx;
				}
				input {
					flex: 1;
					height: 60rpx;
					padding-left: 30rpx;
					
				}
				.ico {
					color: #bbb;
					font-size: 46rpx;
				}
			}
			.arrow_region {
				display: flex;
				justify-content: space-between;
				font-size: 24rpx;
				.left {
				}
				.right {
				}
			}
			.btn {
				margin-top: 40rpx;
				height: 100rpx;
				border-radius: 60rpx;
				width: 100%;
				text-align: center;
				line-height: 100rpx;
				color: #fff;
				background: -webkit-linear-gradient(315deg, rgba(255, 88, 155, 0.6) 0%, #ff589b 100%);
				box-shadow: 0 0.3rem 0.8rem rgba(255,88,155,.4);
			}
		}
	}
	.top_region {
		padding: 0 20rpx 40rpx;
		box-sizing: border-box;
		.title {
			display: flex;
			justify-content: space-between;
			padding: 20rpx 0;
			box-sizing: border-box;
			align-items: center;
			font-size: 36rpx;
			.left {
			}
			.right {
				display: flex;
				align-items: center;
				.text {
					margin-right: 10rpx;
				}
				.ico {
					color: #ff6f6f;
				}
			}
		}
		.content {
			display: flex;
			flex-flow: wrap;
			.item {
				width: 25%;
				display: flex;
				flex-flow: column;
				align-items: center;
				margin: 24rpx 0;
				i {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
					display: flex;
					justify-content: center;
					align-items: center;
					color: #fff;
					font-size: 36rpx;
					position: relative;
					b {
						position: absolute;
						top: -0.5rem;
						right: -0.5rem;
						min-width: 0.8em;
						height: 0.8em;
						padding: 0.3rem;
						text-align: center;
						line-height: 0.8em;
						font-size: 22rpx;
						background: rgba(251, 92, 92, 0.8);
						font-style: normal;
						color: #fff !important;
						border-radius: 1.2em;
					}
				}
				.iconImg {
					width: 80rpx;
					height: 80rpx;
					border-radius: 50%;
				}
				._index {
					background-color: #8addb9;
					background-image: -webkit-linear-gradient(135deg, #ff6f6f, #ffa2a2);
				}

				._huxuan {
					background-color: #8addb9;
					background-image: -webkit-linear-gradient(135deg, #43c38b, #8addb9);
				}

				._trend {
					background-color: #fd6eba;
					background-image: -webkit-linear-gradient(135deg, #fd6eba, #ffabd8);
				}

				._tg {
					background-color: #0dd068;
					background-image: -webkit-linear-gradient(135deg, #0dd068, #77e5aa);
				}

				._dating {
					background-color: #ea4c89;
					background-image: -webkit-linear-gradient(135deg, #ea4c89, #ff8eba);
				}

				._video {
					background-color: #6dadff;
					background-image: -webkit-linear-gradient(135deg, #6dadff, #b0ccef);
				}

				._shop {
					background-color: #ff9966;
					background-image: -webkit-linear-gradient(135deg, #ff9966, #ffd09d);
				}

				._hb {
					background-color: #ff604a;
					background-image: -webkit-linear-gradient(135deg, #ff794a, #ffb196);
				}

				._hn {
					background-color: #fd5941;
					background-image: -webkit-linear-gradient(135deg, #fd5941, #ff9586);
				}

				._myhn {
					background-color: #db7798;
					background-image: -webkit-linear-gradient(135deg, #db7798, #f29db9);
				}

				._party {
					background-color: #feb118;
					background-image: -webkit-linear-gradient(135deg, #feb118, #ffca60);
				}

				._article {
					background-color: #00d8d9;
					background-image: -webkit-linear-gradient(135deg, #0ebfc0, #9eebeb);
				}

				._qun {
					background-color: #d88cff;
					background-image: -webkit-linear-gradient(135deg, #d88cff, #ecc6ff);
					font-size: 2.2rem;
				}

				._msg {
					background-color: #4ebdf1;
					background-image: -webkit-linear-gradient(135deg, #4ebdf1, #8fdbff);
				}

				._vip {
					background-color: #d86ea3;
					background-image: -webkit-linear-gradient(135deg, #b28850, #d9b686);
				}
			}
		}
	}
}
</style>
